﻿using AspectCoreDemo.Transaction.Host.Models;
using Microsoft.EntityFrameworkCore;

namespace AspectCoreDemo.Transaction.Host.Repositories
{
    public class OrderRepository : IOrderRepository
    {
        private readonly AppDbContext _appDbContext;

        public OrderRepository(AppDbContext appDbContext)
        {
            _appDbContext = appDbContext;
        }

        public async Task<Order> Create(Order order)
        {
            await _appDbContext.Orders.AddAsync(order);
            await _appDbContext.SaveChangesAsync();
            return order;
        }

        public async Task<List<Order>> GetAll()
        {
            return await _appDbContext.Orders.ToListAsync();
        }
    }
}
